package View

import ControllerView.ControllerView
import com.trolltech.qt.gui._
import com.trolltech.qt.core._
import com.trolltech.qt.core.QEasingCurve.Type

/**
 * Created by IntelliJ IDEA.
 * User: danymorard
 * Date: 13.04.11
 * Time: 16:21
 * To change this template use File | Settings | File Templates.
 */

class CreateProjectWindow(controller: ControllerView, parent: QWidget) extends View(controller, parent) {


  /**
   * Size of the window
   */
  protected val WINDOW_SIZE = new QSize(700, 569)

  /**
   * Position Y of the button
   */
  protected val POSITION_Y_BUTTON = 536


  protected var backgroundPicture = new QLabel(this)

  var buttonNext = new QPushButton(this)
  var buttonCancel = new QPushButton(this)
  var buttonPrevious = new QPushButton(this)


  /**
   * red point to inform about step
   */
  var redPoint = new QLabel(this)
  protected var animationPoint = new QPropertyAnimation(redPoint, new QByteArray("geometry"))


  this.initView


  /**
   * Initialise the window
   */
  protected def initView {



    // Define the size of the window
    this.setFixedSize(WINDOW_SIZE)

    // Center the window in the middle of the screen
 /*   var screenWidget = QApplication.desktop
    this.move(screenWidget.width / 2 - WINDOW_SIZE.width / 2,
      screenWidget.height / 2 - WINDOW_SIZE.height / 2)
   */
    //init red point
    redPoint.setPixmap(new QPixmap(PATH_PICTURE + "redPoint.png"))
    redPoint.setGeometry(102,54,15,15)


    // set the title and the icon on the window
    this.setBackgroundWithPathSoft
    this.setWindowTitle("Create a new project")


    // set the background image of the window
    backgroundPicture.setGeometry(0, 0, WINDOW_SIZE.width, WINDOW_SIZE.height)


    // add the button
    this.addButton
  }

  /**
   * Add the buttons to the window and connect slot
   */
  private def addButton {

    // Configure the cancel button
    buttonCancel.setGeometry(50, POSITION_Y_BUTTON, SMALL_BUTTON_SIZE.width, SMALL_BUTTON_SIZE.height)
    buttonCancel.setText("Cancel")
    buttonCancel.setObjectName(CSS_SMALL_BUTTON)
    buttonCancel.clicked.connect(controller, "cancelButtonClicked()")


    // configure the next button
    buttonNext.setGeometry(575, POSITION_Y_BUTTON, SMALL_BUTTON_SIZE.width, SMALL_BUTTON_SIZE.height)
    buttonNext.setText("Next")
    buttonNext.setObjectName(CSS_SMALL_BUTTON)
    buttonNext.clicked.connect(controller, "nextButtonClicked()")


    // configure the previous button
    buttonPrevious.setGeometry(480, POSITION_Y_BUTTON, SMALL_BUTTON_SIZE.width, SMALL_BUTTON_SIZE.height)
    buttonPrevious.setText("Previous")
    buttonPrevious.setObjectName(CSS_SMALL_BUTTON)
    buttonPrevious.clicked.connect(controller, "previousButtonClicked()")

  }


  def animationViewPoint(xStartAnimation: Int, xEndAnimation: Int) {

    // move slide
    animationPoint.setStartValue(new QRect(xStartAnimation, redPoint.pos.y, redPoint.width, redPoint.height))
    animationPoint.setEndValue((new QRect(xEndAnimation, redPoint.pos.y, redPoint.width, redPoint.height)))
    animationPoint.setDuration(DURATION_ANIMATION_SLIDE)
    animationPoint.setEasingCurve(new QEasingCurve(Type.InOutQuint))
    animationPoint.start

  }

  def setBackgroundWithoutPathSoft{
         backgroundPicture.setPixmap(new QPixmap(PATH_PICTURE + "createViewBackgroundWithoutImport.jpg"))

  }

  def setBackgroundWithPathSoft{
        backgroundPicture.setPixmap(new QPixmap(PATH_PICTURE + "createViewBackground.png"))
  }

}